#!/bin/bash

if [ -z $1 ] || [ ! -d $1 ]; then
	path=~/.m2/repository
else
	path=$1
fi

echo $path
cd $path
echo "start search" $(pwd)

# 递归函数的实现
function Searchfile()
{
    pomfilelist=$(ls | grep *.pom)
	jarfilelist=$(ls | grep *.jar)
	if [[ ! -z $pomfilelist ]] && [[ -z $jarfilelist ]]; then
		temp=$(pwd)
		cd ..
		echo remove dir $temp
		#rm -rf $temp
		return 0;
	else
		dirlist=$(ls)
		for dirname in $dirlist
		 do
			if [ -d "$dirname" ]; then
				cd $dirname
				Searchfile
				if [ $? == 1 ]; then
					cd ..
				fi
			fi
		 done
	 fi
	return 1;
}

#Searchfile
echo done